<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Site extends Model
{
    //
    protected $fillable = [
        'name', 'user_id', 'url', 'column_id', 'area_id', 'keywords', 'description', 'icon', 'content', 'is_best', 'is_top', 'is_pay', 'state'
    ];

    protected $casts = [
        'content' => 'json',
    ];

    public function area()
    {
        return $this->belongsTo('App\Models\Area');
    }
    public function column()
    {
        return $this->belongsTo('App\Models\Column');
    }
    public function icp()
    {
        return $this->hasOne('App\Models\Icp');
    }
    public function tags()
    {
        return $this->belongsToMany(Tag::class)->withTimestamps();
    }

    public function user()
    {
        return $this->belongsTo(User::class);
    }
}
